//
//  CHomeFilterView.m
//  Btpin
//
//  Created by Vic on 2019/12/18.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "CHomeFilterView.h"
#import "CHomeFilterBaseInfoView.h"

@interface CHomeFilterView ()<CHomeFilterBaseInfoViewDelegate>

@end

@implementation CHomeFilterView

- (instancetype)initWithFrame:(CGRect)frame target:(id)target {
    self = [super initWithFrame:frame];
    if (self) {
        self.filterShowFlag = NO;
        [self initUI];
        self.delegate = target;
    }
    return self;
}
- (void)initUI {
    self.backgroundColor = COLOR_OF_WHITE;
    UIView *bgTopView = [UIToolsControl initViewWithFrame:CGRectMake(0, HeightOfStatusBar, WIDTH, 44) backgroundColor:COLOR_OF_WHITE];
    [self addSubview:bgTopView];
    [bgTopView borderColor:THEMECOLOR_OF_Line_Color borderWidth:lineH borderType:BorderSideTypeBottom];
    
    UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake((WIDTH-ScalePS(200))*0.5, 0, ScalePS(200), 44) text:@"筛选" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    titleLbl.font = FontBold(Font_18);
    titleLbl.textAlignment = NSTextAlignmentCenter;
    [bgTopView addSubview:titleLbl];
    
    UIButton *leftBtn = [UIToolsControl initButtonWithFrame:CGRectMake(10, 0, 44, 44) imageName:@"back_b" target:self action:@selector(dismissView) title:nil titleColor:nil];
//    leftBtn.imageEdgeInsets = UIEdgeInsetsMake(11, 0, 12, 32);
    [bgTopView addSubview:leftBtn];
    
    CHomeFilterBaseInfoView *baseInfoView = [[CHomeFilterBaseInfoView alloc] initWithFrame:CGRectMake(0, EndY(bgTopView), WIDTH, HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar) target:self];
    [self addSubview:baseInfoView];
}
- (void)showView {
    self.filterShowFlag = YES;
    __weak __typeof(self)weakSelf = self;
    [UIView animateWithDuration:0.3 animations:^{
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        CGRect frame = strongSelf.frame;
        frame.origin.x = 0;
        strongSelf.frame = frame;
    }];
}
- (void)dismissView {
    self.filterShowFlag = NO;
    __weak __typeof(self)weakSelf = self;
    [UIView animateWithDuration:0.3 animations:^{
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        CGRect frame = strongSelf.frame;
        frame.origin.x = WIDTH;
        strongSelf.frame = frame;
    }];
}
- (void)cHomeFilterAreaViewCancel {
    [self dismissView];
}
- (void)cHomeFilterBaseInfoViewOkWage:(NSString *)wage experience:(NSString *)experience education:(NSString *)education {
    if (self.delegate && [self.delegate respondsToSelector:@selector(cHomeFilterViewBaseInfoOkWage:experience:education:)]) {
        [self.delegate cHomeFilterViewBaseInfoOkWage:wage experience:experience education:education];
    }
    [self dismissView];
}

@end
